package com.syedu.day08.homework;

import java.time.LocalDate;

import static com.syedu.day08.homework.EmployeeFactory.*;

/**
 * @Description 测试类
 * @createTime 2022/3/17 17:05
 * @author Administrator
 */
public class TestEmployee {
    public static void main(String[] args) {
        /*Employee salariedEmployee = new SalariedEmployee("jack", LocalDate.of(1999, 2, 5), 10000);
        Employee hourlyEmployee = new HourlyEmployee("rose", LocalDate.of(2000, 8, 8), 20, 200);
        Employee salesEmployee = new SalesEmployee("tom", LocalDate.of(2002, 12, 8), 1000000.0, 0.01);
        BasedPlusSalesEmployee basedPlusSalesEmployee = new BasedPlusSalesEmployee("jeff", LocalDate.of(1990, 6, 10), 1000000, 0.01, 3000);
*/

        //Employee employee = EmployeeFactory.getEmployee(EmployeeFactory.HOURLY_EMPLOYEE);
        Employee employee = getEmployee(HOURLY_EMPLOYEE);

        //工厂创建出来的对象时通用对象,即属性值都是默认值
        //设置属性值
        //1.公共属性,直接set设置
        employee.setName("rose");
        employee.setBirthday(LocalDate.of(2000, 8, 8));

        //2.特有属性,需要先强制类型转换,然后再set设置
        //注意: 转换之前最好先进行类型判断,避免出现类型转换异常: java.lang.ClassCastException
        HourlyEmployee hourlyEmployee = (HourlyEmployee) employee;
        hourlyEmployee.setHours(200);
        hourlyEmployee.setPayEachHour(20);
        EmployeeService service = new EmployeeService();
        System.out.println(service.calcSalary(employee, 12));
    }
}
